<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
	<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link href="<%=request.getContextPath()%>/resource/css/index_work.css"
	rel="stylesheet" />
<script type="text/javascript"
	src="<%=request.getContextPath()%>/resource/js/jquery-1.8.2.min.js"></script>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

<table>
  <tr>
    <th>id</th>
    <th>用户名</th>
    <th>注册时间</th>
    <th>角色</th>
    <th>状态</th>
    <th>操作</th>
  </tr>
  
  <c:forEach items="${userPage.list}" var="user">
  	<tr>
  		<td>${user.id }</td>
  		<td>${user.username }</td>
  		<td>
  		<fmt:formatDate value="${user.createTime }" pattern="yyyy-MM--dd"/>
  		</td>
  		<td>${user.role==1?'管理员':'注册用户' }</td>
  		<td>${user.locked==1?'被封':'正常' }</td>
  		
  		<td>
  			<c:if test="${user.locked==1 }">
  				<button type="button" onclick="userlock(${user.id},0)">解禁</button>
  			</c:if>
  			<c:if test="${user.locked==0 }">
  				<button type="button" onclick="userlock(${user.id},1)">封禁</button>
  			</c:if>
  			
  		</td>
  	</tr>
  </c:forEach>
</table>

<nav aria-label="...">
	<ul class="pagination">
		<li><a href="javascript:goPage(${userPage.prePage })">&laquo;</a> </li>
		<c:forEach begin="${userPage.pageNum-2>1?userPage.pageNum-2:1}" end="${userPage.pageNum+2>userPage.pages?
		userPage.pages:userPage.pageNum+2 }" varStatus="index">
		<c:if test="${userPage.pageNum!=index.index }">
			<li><a href="javascript:goPage(${index.index })">${index.index }</a> </li>
		</c:if>
		<c:if test="${userPage.pageNum==index.index }">
			<li><a href="javascript:void"><strong>${index.index }</strong>  </a></li>
		</c:if>
		</c:forEach>
	</ul>
</nav>

<script type="text/javascript">
	function goPage(page){
		$("#workContent").load("/admin/userlist?page="+page)
	}
</script>
</body>
</html>